%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 Vincent On. [vincenton001-at-gmail.com]

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

val = get( handles.popupmenu1, 'Value' );
if isfield(handles,'tracks')
    tracks = handles.tracks;
    cc = handles.cc;
end


switch val
    case 1
        imshow( mov( num ).original, [], 'Parent',  handles.axes1 );
    case 2
        imshow( mov( num ).segmented, [], 'Parent',  handles.axes1 );
    case 3
        track_num = str2double( get( handles.track_edit, 'String' ) );
        
        s_frame = tracks( track_num ).start_frame;
        frames_in_track = s_frame : s_frame + numel(tracks( track_num ).cc_label) - 1;
        
        if ismember(num,frames_in_track)
            temp = zeros( size(mov(1).segmented));
            cc_idx = find(frames_in_track==num);
            idx = tracks( track_num ).cc_label( cc_idx );
            temp(cc{ num }.PixelIdxList{ idx }) = 1;
            temp = bwmorph( temp, 'remove' );
            temp = bwmorph( temp, 'thicken', 3 );
            
            temp2 = mov( num ).original;
            temp2( temp == 1 ) = 255;
            
            imshow( temp2, [], 'Parent',  handles.axes1 );
        else
            imshow( mov( num ).original, [], 'Parent',  handles.axes1 );
        end
end